#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	long long num=0;
	string s;
	long long sum = 0;
	cin >> s >> num;
	for (int i = 0; i < num; i++)
	{
		sum += s[i] - '0';
	}
	cout << sum;
	return 0;
}